<template>
	<view class="content bgGray">
		<view class="bgWhite flex-r jsb p16" style="border-bottom: 1rpx solid #eee">
			<view>商户名称</view>
			<view class="gray f1">
				<input type="text" class="textRight" v-model="form.tMerchantname" style="width: 100%" />
			</view>
		</view>
		<view class="bgWhite ver-c p16">
			<view class="mb16">营业执照和门面照片</view>
			<view class="flex-r upload-img wrap">
				<view v-for="(image, imgIndex) in fileList" :key="imgIndex">
					<view class="uni-uploader__file">
						<image
							class="uni-uploader__img"
							:src="image.ip + image.url"
							:data-src="image.url"
							@click="preview(image.ip + image.url)"
							@longtap="onDeleteClick(imgIndex, index)"
						></image>
					</view>
				</view>
			</view>
		</view>
		<!-- <view class="bgWhite mt6 flex-r jsb p16" style="border-bottom: 1rpx solid #eee">
			<view>信用代码</view>
			<view class="gray f1">
				<input type="text" class="textRight" v-model="form.tMerchantcreditcode" style="width: 100%" />
			</view>
		</view> -->
		<view class="bgWhite mt6 flex-c jsb p16" style="border-bottom: 1rpx solid #eee">
			<view>商铺介绍</view>
			<view class="gray mt16 f1">
				<textarea
					class="fs13"
					style="
						background: #eee;
						height: 140rpx;
						width: 100%;
						padding: 20rpx;
						box-sizing: border-box;
						border-radius: 20rpx;
					"
					v-model="form.tMerchantintroduce"
				/>
			</view>
		</view>
		<view class="bgWhite mt6 flex-r jsb p16" style="border-bottom: 1rpx solid #eee">
			<view>联系人</view>
			<view class="gray f1">
				<input type="text" class="textRight" v-model="form.tMerchantcontacts" style="width: 100%" />
			</view>
		</view>
		<view class="bgWhite flex-r jsb p16" style="border-bottom: 1rpx solid #eee">
			<view>电话</view>
			<view class="gray f1">
				<input type="text" class="textRight" v-model="form.tMerchantphone" style="width: 100%" />
			</view>
		</view>
		<view class="bgWhite flex-r jsb p16" style="border-bottom: 1rpx solid #eee">
			<view>微信号</view>
			<view class="gray f1">
				<input type="text" class="textRight" v-model="form.tMerchantwechat" style="width: 100%" />
			</view>
		</view>
		<view class="bgWhite p16" style="border-bottom: 1rpx solid #eee">
			<view>商户地址</view>
			<view class="gray f1 mt16">
				<textarea
					class="fs13"
					style="
						background: #eee;
						height: 140rpx;
						width: 100%;
						padding: 20rpx;
						box-sizing: border-box;
						border-radius: 20rpx;
					"
					v-model="form.tMerchantaddress"
					disabled
				/>
			</view>
			<view class="fs13 gray mt10">
				提示：店铺地址授权后自动定位，请确定店铺位置后定位，这将直接影响用户导航到店位置！
			</view>
		</view>
		<view class="bgWhite p16" style="border-bottom: 1rpx solid #eee">
			<view>地址门牌号</view>
			<view class="gray f1 mt16" style="width: 100%">
				<textarea
					class="fs13"
					style="
						background: #eee;
						height: 140rpx;
						width: 100%;
						padding: 20rpx;
						box-sizing: border-box;
						border-radius: 20rpx;
					"
					v-model="form.tSpecificaddress"
				/>
			</view>
		</view>
		<!-- <view class="savebtn textCenter mb16 white" @tap="save()">保存</view> -->
	</view>
</template>

<script>
import Utils from '@/utils/utils.js'
import { IP, ImgIP, throttle } from '@/utils/comm.js'
import { getShopInfo } from '@/api/mine.js'
//import amapFile from '@/utils/map/amap-wx.130.js' // 高德
//import QQMapWX from '@/utils/map/qqmap-wx-jssdk.min.js'
export default {
	data() {
		return {
			fileList: [], //上传图片
			token: '',
			form: {
				tMerchantid: '',
				tMerchantname: '',
				tMerchantcontacts: '',
				tMerchantphone: '',
				tMerchantaddress: '',
				tMerchantlicenseimg: '', //图片
				tLongitude: '',
				tLatitude: ''
			}
		}
	},

	onLoad(option) {
		console.log('?', option.tMerchantid)
		this.form.tMerchantid = option.tMerchantid
		getShopInfo(this.form.tMerchantid).then((res) => {
			this.form = res.tMerchantinfo
			if (res.tMerchantinfo.tMerchantlicenseimg) {
				this.fileList = res.tMerchantinfo.tMerchantlicenseimg.split(',').map((item) => {
					return {
						url: item,
						ip: ImgIP
					}
				})
				console.log('fileList->', this.fileList)
			}
		})
	},
	onShow() {},
	methods: {
		// 预览图片
		preview(img) {
			console.log('预览')
			// 新建一个存放预览图片的空数组
			var imgArr = []
			imgArr.push(img)
			uni.previewImage({
				urls: imgArr,
				current: imgArr[0],
				longPressActions: {}
			})
		}
	}
}
</script>

<style lang="stylus" scoped>
.content
	height 100%
.mt6
	margin-top 12rpx
.savebtn
	margin 40rpx 32rpx 0
	border-radius 50rpx
	background #c40414
	line-height 90rpx
.img
	padding 60rpx 50rpx
	background #f5f5f5
	border-radius 14rpx
	width 50rpx
	height 40rpx
.uni-uploader__img
	width 150rpx
	height 150rpx
	border-radius(14rpx)
	margin 5rpx
</style>
